package org.adorsys.aderp.jpa.impl;

import java.util.HashMap;
import java.util.Map;


public class RepositoryMap {
//	
//	private ApplicationContext applicationContext;
//	
	private Map<Class<?>, AderpJPARepository> repositoryMap = new HashMap<Class<?>, AderpJPARepository>();
	
//	@Override
//	public void setApplicationContext(ApplicationContext applicationContext)
//			throws BeansException {
//		this.applicationContext = applicationContext;
//	}
	
//	@SuppressWarnings({ "rawtypes", "unchecked" })
//	public AderpJPARepository getAderpJPARepository(Class<?> jpaKlass){
//		Map<String, JpaRepository> beansOfType = applicationContext.getBeansOfType(JpaRepository.class);
//		Collection<JpaRepository> values = beansOfType.values();
//		for (JpaRepository jpaRepository : values) {
//			AderpJPARepository repo = (AderpJPARepository) jpaRepository;
//			if(repo.isEntityKlass(jpaKlass)) return repo;
//		}
//		return null;
//	}
	
	public void put(Class<?> klass, AderpJPARepository jpaRepository){
		repositoryMap.put(klass, jpaRepository);
	}
	
	public AderpJPARepository get(Class<?> klass){
		return repositoryMap.get(klass);
	}

}
